import delimited using globalterrorismdb_0718dist.csv
set more off 

** the packages combomarginsplot and grc1leg2 are needed to run this file

drop nreleased addnotes scite1 scite2 scite3 dbsource int_log int_ideo int_misc int_any related
**Generate new variable with numeric codes for list groups**
drop country provstate city multiple  attacktype1_txt attacktype3_txt attacktype2_txt targsubtype1 target1 natlty1  target2 natlty2 target3 natlty3 gsubname gname2 gsubname2 gname3  guncertain1 guncertain2 nperps nperpcap claimed claim2 claim3 compclaim weaptype1 weapsubtype1 weaptype2 weapsubtype2 weaptype3 weapsubtype3 property 
**
drop resolution latitude longitude approxdate vicinity specificity location summary crit1 crit2 crit3 doubtterr alternative alternative_txt                                                
drop corp2 corp1 corp3 gsubname3 guncertain3 individual claimmode claimmode_txt claimmode2 claimmode2_txt claimmode3 claimmode3_txt propcomment propextent_txt ishostkid nhostkid nhostkidus nhours ndays divert kidhijcountry ransomamtus ransompaid ransompaidus ransomnote hostkidoutcome hostkidoutcome_txt

replace gname="al-Qaeda" if gname=="Al-Qaida"
replace gname="Ansar al-Dine" if gname=="Ansar al-Dine (Mali)"
 replace gname="Ansar al-Dine" if gname=="Ansar al-Din"
  replace gname="Aum ShinriKyo" if gname=="Aum Shinri Kyo"
replace gname="Democratic Front for the Liberation of Palestine" if gname=="Democratic Front for the Liberation of Palestine (DFLP)"
replace gname="al-Gama'at al-Islamiyya (IG)" if gname=="Al-Gama'at al-Islamiyya (IG)"
replace gname="Hamas" if gname=="Hamas (Islamic Resistance Movement)"
replace gname="Harkat ul-Mujahedin" if gname=="Harakat ul-Mujahidin (HuM)"
replace gname="Hezbollah Palestine" if gname=="Hezbollah"
replace gname="Islamic State of Iraq and the Levant (ISIL)" if gname=="Al-Qaida in Iraq"
replace gname="Islamic State of Iraq and the Levant (ISIL)" if gname=="Islamic State of Iraq (ISI)"
replace gname="Islamic Movement of Uzbekistan" if gname=="Islamic Movement of Uzbekistan (IMU)"
replace gname="Jundallah (Iran)" if gname=="Jundallah (Pakistan)"
replace gname="Kurdistan Workers Party(PKK)" if gname=="Kurdistan Workers' Party (PKK)"
replace gname="Mujahideen-I-Khalq" if gname=="Mujahedin-e Khalq (MEK)"
replace gname="Popular Front for the Liberation of Palestine-General Command (PFLP-GC)" if gname=="Popular Front for the Liberation of Palestine, Gen Cmd (PFLP-GC)"
replace gname="Shining Path" if gname=="Shining Path (SL)"
replace gname="Tehrik-i-Taliban Pakistan(TTP)" if gname=="Tehrik-i-Taliban Pakistan (TTP)"
replace gname="United Self Defense Forces of Colombia (AUC)" if gname=="United Self Defense Units of Colombia (AUC)"
replace gname="Al-Qaida in the Islamic Maghreb (AQIM)" if gname=="Salafist Group for Preaching and Fighting (GSPC)"


gen gid=.
  replace gid=1 if gname=="1920 Revolution Brigades"
replace gid=2 if gname=="23rd of September Communist League"
replace gid=3 if gname=="28 May Armenian Organization"
replace gid=4 if gname=="2nd of June Movement"
replace gid=5 if gname=="313 Brigade"
replace gid=6 if gname=="Abdullah Azzam Brigades"
replace gid=7 if gname=="Abu Bakr al-Siddiq Fundamentalist Brigades (Iraq)"
replace gid=8 if gname=="Abu Hafs al-Masri Brigades"
replace gid=9 if gname=="Abu Nidal Organization (ANO)"
replace gid=10 if gname=="Abu Salim Martyr's Brigade"
replace gid=11 if gname=="Abu Sayyaf Group (ASG)"
replace gid=12 if gname=="Achik National Volunteer Council (ANVC)"
replace gid=13 if gname=="Actiefront Nationalistisch Nederland"
replace gid=14 if gname=="Action Directe"
replace gid=15 if gname=="Action Front for the Liberation of the Baltic Countries"
replace gid=16 if gname=="Adan Abyan Islamic Army"
replace gid=17 if gname=="Adivasi National Liberation Army (ANLA)"
replace gid=18 if gname=="Adivasi People's Army (APA)"
replace gid=19 if gname=="Afar Revolutionary Democratic Unity Front"
replace gid=20 if gname=="Africa Marine Commando"
replace gid=21 if gname=="African National Congress (South Africa)"
replace gid=22 if gname=="Ahlu-sunah Wal-jamea (Somalia)"
replace gid=23 if gname=="Ahrar Al-Jalil (Free People of the Galilee)"
replace gid=24 if gname=="Ahrar al-Sham"
replace gid=25 if gname=="Aisha Umm-al Mouemeneen"
replace gid=26 if gname=="Ajnad Misr"
replace gid=27 if gname=="Ajnad al-Sham"
replace gid=28 if gname=="Akhil Terai Mukti Morcha (ATMM)"
replace gid=29 if gname=="Al Borkan Liberation Organization"
replace gid=30 if gname=="Al Faran"
replace gid=31 if gname=="Al Hadid"
replace gid=32 if gname=="Al Zulfikar"
replace gid=33 if gname=="Al-Aqsa Martyrs Brigade"
replace gid=34 if gname=="Al-Arifeen"
replace gid=35 if gname=="Al-Furqan Brigades"
replace gid=36 if gname=="Al-Islah party"
replace gid=37 if gname=="Al-Khobar"
replace gid=38 if gname=="Al-Mansoorian"
replace gid=39 if gname=="Al-Mua'qi'oon Biddam Brigade"
replace gid=40 if gname=="Al-Naqshabandiya Army"
replace gid=41 if gname=="Al-Nasireen Group"
replace gid=42 if gname=="Al-Nawaz"
replace gid=43 if gname=="Al-Nusrah Front"
replace gid=45 if gname=="Al-Qaida in the Indian Subcontinent"
replace gid=46 if gname=="Al-Qaida in the Islamic Maghreb (AQIM)"
replace gid=47 if gname=="Al-Qaqa Brigade"
replace gid=48 if gname=="Al-Sa'iqa"
replace gid=49 if gname=="Al-Sadr Brigades"
replace gid=50 if gname=="Al-Sawaiq Brigade"
replace gid=51 if gname=="Al-Shabaab"
replace gid=52 if gname=="Al-Shuda Brigade"
replace gid=53 if gname=="Al-Umar Mujahideen"
replace gid=54 if gname=="Al-Ummah"
replace gid=55 if gname=="Al-Yakin Mujahidin"
replace gid=56 if gname=="Albanian National Army (ANA)"
replace gid=57 if gname=="Alejo Calatayu"
replace gid=58 if gname=="Alex Boncayao Brigade (ABB)"
replace gid=59 if gname=="Algeria Province of the Islamic State"
replace gid=60 if gname=="All Burma Students' Democratic Front (ABSDF)"
replace gid=61 if gname=="All Nepal National Free Student Union-Revolutionary"
replace gid=62 if gname=="All Tripura Tiger Force (ATTF)"
replace gid=63 if gname=="Alliance of Patriots for a Free and Sovereign Congo"
replace gid=64 if gname=="Allied Democratic Forces"
replace gid=65 if gname=="Amal"
replace gid=66 if gname=="Amr Bil Maroof Wa Nahi Anil Munkir"
replace gid=67 if gname=="Ananda Marga"
replace gid=68 if gname=="Andres Castro United Front (FUAC)"
replace gid=69 if gname=="Angry Brigade (Italy)"
replace gid=70 if gname=="Animal Liberation Front"
replace gid=71 if gname=="Animal Rights Militia"
replace gid=72 if gname=="Ansar Al-Khilafa"
replace gid=73 if gname=="Ansar Allah"
replace gid=74 if gname=="Ansar Bayt al-Maqdis (Ansar Jerusalem)"
replace gid=75 if gname=="Ansar Wa Mohajir (Pakistan)"
replace gid=76 if gname=="Ansar al-Din Front"
replace gid=77 if gname=="Ansar al-Dine"
replace gid=78 if gname=="Ansar al-Furqan"
replace gid=79 if gname=="Ansar al-Islam"
replace gid=80 if gname=="Ansar al-Jihad"
replace gid=81 if gname=="Ansar al-Sharia (Libya)"
replace gid=82 if gname=="Ansar al-Sunnah Army"
replace gid=83 if gname=="Ansaru (Jama'atu Ansarul Muslimina Fi Biladis Sudan)"
replace gid=84 if gname=="Ansarul Islam(Pakistan)"
replace gid=85 if gname=="Ansarullah Bangla Team"
replace gid=86 if gname=="Anti-American Arab Liberation Front"
replace gid=87 if gname=="Anti-Armenian Organization"
replace gid=88 if gname=="Anti-Balaka"
replace gid=89 if gname=="Anti-Communist Command"
replace gid=90 if gname=="Anti-Imperialist Cell (AIZ)"
replace gid=91 if gname=="Anti-Imperialist International Brigades"
replace gid=92 if gname=="Anti-Imperialist Territorial Nuclei (NTA)"
replace gid=93 if gname=="Anti-Racist Guerrilla Nuclei"
replace gid=94 if gname=="Anti-Zionist Movement"
replace gid=95 if gname=="Anti-terrorist Liberation Group (GAL)"
replace gid=96 if gname=="Aqmur"
replace gid=97 if gname=="Arab Communist Organization"
replace gid=98 if gname=="Arab Liberation Front (ALF)"
replace gid=99 if gname=="Arab Movement of Azawad"
replace gid=100 if gname=="Arab People's Group"
replace gid=101 if gname=="Arab Revolutionary Front"
replace gid=102 if gname=="Arabian Peninsula Freemen"
replace gid=103 if gname=="Arakan Army (AA)"
replace gid=104 if gname=="Arakan Liberation Party"
replace gid=105 if gname=="Arauco Malleco Coordinating Group (CAM) - Chile"
replace gid=106 if gname=="Arbav Martyrs of Khuzestan"
replace gid=107 if gname=="Argentine Anti-Communist Alliance"
replace gid=108 if gname=="Armata Corsa"
replace gid=109 if gname=="Armata di Liberazione Naziunale (ALN)"
replace gid=110 if gname=="Armed Commandos of Liberation"
replace gid=111 if gname=="Armed Forces of National Resistance (FARN)"
replace gid=112 if gname=="Armed Islamic Group (GIA)"
replace gid=113 if gname=="Armed Revolutionary Action (ENEDRA)"
replace gid=114 if gname=="Armenian Red Army"
replace gid=115 if gname=="Armenian Revolutionary Army"
replace gid=116 if gname=="Armenian Secret Army for the Liberation of Armenia"
replace gid=117 if gname=="Army of Islam"
replace gid=118 if gname=="Army of State Liberators"
replace gid=119 if gname=="Arnoldo Camu Command"
replace gid=120 if gname=="Aryan Nations (U.S.)"
replace gid=121 if gname=="Asa'ib Ahl al-Haqq"
replace gid=122 if gname=="Asbat al-Ansar"
replace gid=123 if gname=="Aum ShinriKyo"
replace gid=124 if gname=="Autonomous Intervention Collective Against the Zionist Presence in France"
replace gid=125 if gname=="Awami League"
replace gid=126 if gname=="Azawad National Liberation Movement(MNLA)"
replace gid=127 if gname=="Baader-Meinhof Group"
replace gid=128 if gname=="Babbar Khalsa"
replace gid=129 if gname=="Bahrain Province of the Islamic State"
replace gid=130 if gname=="Baloch Liberation Army"
replace gid=131 if gname=="Baloch Liberation Front(BLF)"
replace gid=132 if gname=="Baloch Liberation Tigers (BLT)"
replace gid=133 if gname=="Baloch Mussalah Diffah Tanzim"
replace gid=134 if gname=="Baloch Republican Army(BRA)"
replace gid=135 if gname=="Baloch Waja Liberation Army"
replace gid=136 if gname=="Balochistan Liberation United Front (BLUF)"
replace gid=137 if gname=="Bangsamoro Islamic Freedom Movement (BIFM)"
replace gid=138 if gname=="Barisan Revolusi Nasional (BRN)"
replace gid=139 if gname=="Barqa Province of the Islamic State"
replace gid=140 if gname=="Basque Fatherland and Freedom (ETA)"
replace gid=141 if gname=="Bengali Sangram Mukti Bahini"
replace gid=142 if gname=="Benghazi Defense Brigades"
replace gid=143 if gname=="Black December"
replace gid=144 if gname=="Black Friday"
replace gid=145 if gname=="Black Hand"
replace gid=146 if gname=="Black September"
replace gid=147 if gname=="Black Star"
replace gid=148 if gname=="Bodo Liberation Tigers (BLT)"
replace gid=149 if gname=="Bodu Bala Sena"
replace gid=150 if gname=="Boere Aanvals Troepe (BAT)"
replace gid=151 if gname=="Boko Haram"
replace gid=152 if gname=="Breton Liberation Front"
replace gid=153 if gname=="Brigade of al-Mukhtar al-Thaqafi"
replace gid=154 if gname=="Brigades of Imprisoned Sheikh Omar Abdel-Rahman"
replace gid=155 if gname=="Brother Julian"
replace gid=156 if gname=="Bru National Liberation Front"
replace gid=157 if gname=="Catholic Reaction Force (CRF)"
replace gid=158 if gname=="Caucasus Emirate"
replace gid=159 if gname=="Caucasus Province of the Islamic State"
replace gid=160 if gname=="Cell for Internationalism"
replace gid=161 if gname=="Charles Martel Group"
replace gid=162 if gname=="Che Guevara Brigade"
replace gid=163 if gname=="Chilean Committee of Support for the Peruvian Revolution"
replace gid=164 if gname=="Chukakuha (Middle Core Faction)"
replace gid=165 if gname=="Cinchoneros Popular Liberation Movement"
replace gid=166 if gname=="Citizen's Rights Protection Volunteers"
replace gid=167 if gname=="Civil Protection Units"
replace gid=168 if gname=="Civilian Joint Task Force"
replace gid=169 if gname=="Clandestini Corsi"
replace gid=170 if gname=="Coalition of National Brigades"
replace gid=171 if gname=="Colonel Karuna Faction"
replace gid=172 if gname=="Combat 18"
replace gid=173 if gname=="Comite d'Action Viticole"
replace gid=174 if gname=="Comit� Argentino de Lucha Anti-Imperialisto (Argentina)"
replace gid=175 if gname=="Committee of Coordination"
replace gid=176 if gname=="Committee of Solidarity with Arab and Middle East Political Prisoners"
replace gid=177 if gname=="Communist Combatant Cells (CCC) (Belgium)"
replace gid=178 if gname=="Communist Party of India- Marxist"
replace gid=179 if gname=="Communist Party of India-Maoists (CPI-Maoist)"
replace gid=180 if gname=="Communist Party of Nepal- Unified Marxist-Leninist (CPN-UML)"
replace gid=181 if gname=="Communist Party of Nepal-Maoists (CPN-M)"
replace gid=182 if gname=="Congolese Patriotic Resistence-Patriotic Armed Forces (Pareco/FAP)"
replace gid=183 if gname=="Conscientious Arsonists (Greece)"
replace gid=184 if gname=="Conspiracy of Cells of Fire"
replace gid=185 if gname=="Continuity Irish Republican Army (CIRA)"
replace gid=186 if gname=="Convention of Patriots for Justice and Peace"
replace gid=187 if gname=="Coordination Committee (CORCOM)"
replace gid=188 if gname=="Coordination of Azawad Movements"
replace gid=189 if gname=="Corsican National Liberation Front"
replace gid=190 if gname=="Counterrevolutionary Solidarity (SC)"
replace gid=191 if gname=="Croatian Freedom Fighters"
replace gid=192 if gname=="Dagestani Shari'ah jamaat"
replace gid=193 if gname=="Dashmesh Regiment"
replace gid=194 if gname=="Deccan Mujahideen"
replace gid=195 if gname=="Defenders of the Nation's Sovereignty"
replace gid=196 if gname=="Delta Democratic Militia"
replace gid=197 if gname=="Democratic Front for the Liberation of Palestine"
replace gid=198 if gname=="Democratic Front for the Liberation of Rwanda (FDLR)"
replace gid=199 if gname=="Democratic Front of the Central African People (FDPC)"
replace gid=200 if gname=="Democratic Karen Buddhist Army (DKBA)"
replace gid=201 if gname=="Democratic Union Party"
replace gid=202 if gname=="Devrimici Halk Kurtulus Cephesi (DHKP/C)"
replace gid=203 if gname=="Dima Halao Daoga (DHD)"
replace gid=204 if gname=="Diraa al-Shahbaa Rebel Brigade"
replace gid=205 if gname=="Donetsk People's Republic"
replace gid=206 if gname=="Dravidar Viduthalai Kazhagam"
replace gid=207 if gname=="Dukhta-ran-e-Millat"
replace gid=208 if gname=="Earth Liberation Front"
replace gid=209 if gname=="Eastern Turkistan Islamic Movement (ETIM)"
replace gid=210 if gname=="Economic Freedom Fighters"
replace gid=211 if gname=="Egypt's Revolution"
replace gid=212 if gname=="Egyptian Tawhid and Jihad"
replace gid=213 if gname=="Ejercito Revolucionaria del Pueblo (ERP) (Argentina)"
replace gid=214 if gname=="English Defense League"
replace gid=215 if gname=="Eritrean Liberation Front (ELF)"
replace gid=216 if gname=="Eritrean Peoples Liberation Front"
replace gid=217 if gname=="Eritrean Salvation Front"
replace gid=218 if gname=="Ethiopian People's Revolutionary Army"
replace gid=219 if gname=="Etnocacerista Movement"
replace gid=220 if gname=="Eva Peron Organization"
replace gid=221 if gname=="Farabundo Marti National Liberation Front (FMLN)"
replace gid=222 if gname=="Farmer's Movement of the Philippines"
replace gid=223 if gname=="Fatah Hawks"
replace gid=224 if gname=="Fatah al-Islam"
replace gid=225 if gname=="Fatherland and Liberty Nationalist Front (Chile)"
replace gid=226 if gname=="February 14th Movement"
replace gid=227 if gname=="February 17 Martyrs Brigade"
replace gid=228 if gname=="February 28 Popular League (El Salvador)"
replace gid=229 if gname=="Fedayeen Khalq (People's Commandos)"
replace gid=230 if gname=="Fezzan Province of the Islamic State"
replace gid=231 if gname=="First of October Antifascist Resistance Group (GRAPO)"
replace gid=232 if gname=="Forbidden Blockade"
replace gid=233 if gname=="Free Aceh Movement (GAM)"
replace gid=234 if gname=="Free Network South (Freies Netz Sued)"
replace gid=235 if gname=="Free Papua Movement (OPM-Organisasi Papua Merdeka)"
replace gid=236 if gname=="Free Syrian Army"
replace gid=237 if gname=="Freedom Eagles of Africa"
replace gid=238 if gname=="Freital Group"
replace gid=239 if gname=="Friends of Freedom"
replace gid=240 if gname=="Front for the Liberation of Lebanon from Foreigners"
replace gid=241 if gname=="Front for the Liberation of the Cabinda Enclave (Angola)"
replace gid=242 if gname=="Front for the Liberation of the French Somali Coast"
replace gid=243 if gname=="Future movement"
replace gid=244 if gname=="Gangs of Conscience"
replace gid=245 if gname=="Garo National Liberation Army"
replace gid=246 if gname=="Generation of Arab Fury"
replace gid=247 if gname=="Global Intifada"
replace gid=248 if gname=="God's Army"
replace gid=249 if gname=="Gracchus Babeuf"
replace gid=250 if gname=="Greek Bulgarian Armenian Front"
replace gid=251 if gname=="Group of Popular Fighters"
replace gid=252 if gname=="Grupo de Combatientes Populares"
replace gid=253 if gname=="Guadeloupe Liberation Army"
replace gid=254 if gname=="Guardsmen of Islam"
replace gid=255 if gname=="Guatemalan Labor Party (Guatemala)"
replace gid=256 if gname=="Guatemalan National Revolutionary Unity (URNG)"
replace gid=257 if gname=="Guerrilla Army of the Poor (EGP)"
replace gid=258 if gname=="Haftar Militia"
replace gid=259 if gname=="Hamas"
replace gid=260 if gname=="Haqqani Network"
replace gid=261 if gname=="Harakat Ansar Iran (HAI)"
replace gid=262 if gname=="Harakat al-Nujaba"
replace gid=263 if gname=="Harkat ul Ansar"
replace gid=264 if gname=="Harkat ul-Mujahedin"
replace gid=265 if gname=="Harkatul Jihad-e-Islami"
replace gid=266 if gname=="Hector Rio De Brigade"
replace gid=267 if gname=="Hekmatyar (Hizb-I Islami Gulbuddin)"
replace gid=268 if gname=="Hezbollah"
replace gid=269 if gname=="Hijaz Province of the Islamic State"
replace gid=270 if gname=="Hill Tiger Force "
replace gid=271 if gname=="Hizb al-Tahrir al-Islami (HT)"
replace gid=272 if gname=="Hizbul Mujahideen (HM)"
replace gid=273 if gname=="Hizbul al Islam"
replace gid=274 if gname=="Hmar People's Convention-Democracy (HPC-D)"
replace gid=275 if gname=="Hynniewtrep National Liberation Council (HNLC)"
replace gid=276 if gname=="Indian Mujahideen"
replace gid=277 if gname=="Indigenous People's Federal Army (IPFA)"
replace gid=278 if gname=="Informal Anarchist Federation"
replace gid=279 if gname=="International Communist Group"
replace gid=280 if gname=="International Justice Group (Gama'a al-Adela al-Alamiya)"
replace gid=281 if gname=="International Revolutionary Action Group (GARI)"
replace gid=282 if gname=="International Solidarity"
replace gid=283 if gname=="Iparretarrak (IK)"
replace gid=284 if gname=="Iraq's Jihadist Leagues"
replace gid=285 if gname=="Iraqi Democratic Front"
replace gid=286 if gname=="Irish National Liberation Army (INLA)"
replace gid=287 if gname=="Irish Republican Army (IRA)"
replace gid=288 if gname=="Islami Jamiat-e-Talaba (IJT)"
replace gid=289 if gname=="Islamic Army in Iraq"
replace gid=290 if gname=="Islamic Brotherhood"
replace gid=291 if gname=="Islamic Courts Union"
replace gid=292 if gname=="Islamic Front (Syria)"
replace gid=293 if gname=="Islamic Jihad Brigades"
replace gid=294 if gname=="Islamic Jihad Group (IJG)"
replace gid=295 if gname=="Islamic Movement for Change"
replace gid=296 if gname=="Islamic Movement of Kashmir"
replace gid=297 if gname=="Islamic Movement of Uzbekistan"
replace gid=298 if gname=="Islamic Resistance"
replace gid=299 if gname=="Islamic Salvation Front (FIS)"
replace gid=300 if gname=="Islamic State in Bangladesh"
replace gid=301 if gname=="Islamic State in the Greater Sahara"
replace gid=302 if gname=="Islamic State of Iraq and the Levant (ISIL)"
replace gid=303 if gname=="Islamic Unification Movement"
replace gid=304 if gname=="Islamic Youth Shura Council"
replace gid=305 if gname=="Izberbash Gang"
replace gid=306 if gname=="Jabha East Africa"
replace gid=307 if gname=="Jaime Bateman Cayon Group (JBC)"
replace gid=308 if gname=="Jaish Al-Umma (Army of the Nation)"
replace gid=309 if gname=="Jaish Usama"
replace gid=310 if gname=="Jaish al-Adl"
replace gid=311 if gname=="Jaish al-Fatah"
replace gid=312 if gname=="Jaish al-Muhajireen wal-Ansar"
replace gid=313 if gname=="Jaish al-Mujahideen (Syria)"
replace gid=314 if gname=="Jaish al-Ta'ifa al-Mansura"
replace gid=315 if gname=="Jaish-e-Islam"
replace gid=316 if gname=="Jaish-e-Mohammad (JeM)"
replace gid=317 if gname=="Jama'atul Mujahideen Bangladesh (JMB)"
replace gid=318 if gname=="Jamaah Ansharut Daulah"
replace gid=319 if gname=="Jamaah Ansharut Tauhid (JAT)"
replace gid=320 if gname=="Jamaat-E-Islami (Bangladesh)"
replace gid=321 if gname=="Jamaat-ul-Ahrar"
replace gid=322 if gname=="Jamiat ul-Mujahedin (JuM)"
replace gid=323 if gname=="Jammu and Kashmir Islamic Front_1"
replace gid=324 if gname=="Jammu and Kashmir Islamic Front_2"
replace gid=325 if gname=="Janatantrik Terai Madhesh Mukti Morcha (JTMMM)"
replace gid=326 if gname=="Janatantrik Terai Mukti Morcha- Jwala Singh"
replace gid=327 if gname=="Janatantrik Terai Mukti Morcha- Prithvi Singh (JTMM-P)"
replace gid=328 if gname=="Janjaweed"
replace gid=329 if gname=="Japanese Red Army (JRA)"
replace gid=330 if gname=="Jemaah Islamiya (JI)"
replace gid=331 if gname=="Jenin Martyrs Brigades"
replace gid=332 if gname=="Jewish Defense League (JDL)_1"
replace gid=333 if gname=="Jewish Defense League (JDL)_2"
replace gid=334 if gname=="Jharkhand Janmukti Parishad (JJP)"
replace gid=335 if gname=="Jharkhand Liberation Tigers (JLT)"
replace gid=336 if gname=="Jihadi Movement of the Sunna People of Iran"
replace gid=337 if gname=="Jordanian Islamic Resistance"
replace gid=338 if gname=="Jund Ansar Allah"
replace gid=339 if gname=="Jund al-Aqsa"
replace gid=340 if gname=="Jund al-Khilafa"
replace gid=341 if gname=="Jund al-Sham for Tawhid and Jihad"
replace gid=342 if gname=="Jundallah (Iran)"
replace gid=343 if gname=="Jundallah(Iran)"
replace gid=344 if gname=="Jundul Khilafah (Philippines)"
replace gid=345 if gname=="June 16 Organization"
replace gid=346 if gname=="Justice Commandos for the Armenian Genocide"
replace gid=347 if gname=="Justice and Equality Movement (JEM)"
replace gid=348 if gname=="Kabataang Makabayan (KM)"
replace gid=349 if gname=="Kach"
replace gid=350 if gname=="Kachin Independence Army"
replace gid=351 if gname=="Kahane Chai"
replace gid=352 if gname=="Kamtapur Liberation Organization (KLO)"
replace gid=353 if gname=="Kanglei Yawol Kanna Lup (KYKL)"
replace gid=354 if gname=="Kangleipak Communist Party"
replace gid=355 if gname=="Karabulak Gang"
replace gid=356 if gname=="Karbi Longri North Cachar Liberation Front (KLNLF)"
replace gid=357 if gname=="Karbi People's Liberation Tigers"
replace gid=358 if gname=="Karen National Union"
replace gid=359 if gname=="Karenni National Progressive Party"
replace gid=360 if gname=="Kata'ib Hezbollah"
replace gid=361 if gname=="Kata'ib al-Khoul"
replace gid=362 if gname=="Khasi Students Union"
replace gid=363 if gname=="Khmer Rouge"
replace gid=364 if gname=="Khorasan Chapter of the Islamic State"
replace gid=365 if gname=="Khristos Kasimis"
replace gid=366 if gname=="Khumbuwan Mukti Morcha"
replace gid=367 if gname=="Kirat Janabadi Workers Party"
replace gid=368 if gname=="Komando Jihad (Indonesian)"
replace gid=369 if gname=="Kosovo Liberation Army (KLA)_1"
replace gid=370 if gname=="Kosovo Liberation Army (KLA)_2"
replace gid=371 if gname=="Ku Klux Klan"
replace gid=372 if gname=="Kuki Liberation Army"
replace gid=373 if gname=="Kuki National Army"
replace gid=374 if gname=="Kuki National Front"
replace gid=375 if gname=="Kuki Revolutionary Army(KRA)"
replace gid=376 if gname=="Kurdish Democratic Party-Iraq (KDP)"
replace gid=377 if gname=="Kurdish Islamic Unity Party"
replace gid=378 if gname=="Kurdistan Free Life Party"
replace gid=379 if gname=="Kurdistan Freedom Hawks (TAK)"
replace gid=380 if gname=="Kurdistan Workers Party(PKK)"
replace gid=381 if gname=="Lahij Province of the Islamic State"
replace gid=382 if gname=="Lashkar-I-Omar"
replace gid=383 if gname=="Lashkar-e-Balochistan"
replace gid=384 if gname=="Lashkar-e-Islam"
replace gid=385 if gname=="Lashkar-e-Jhangvi"
replace gid=386 if gname=="Lashkar-e-Taiba (LeT)"
replace gid=387 if gname=="Laskar Jihad (LJ)"
replace gid=388 if gname=="Lebanese Armed Revolutionary Faction (LARF)"
replace gid=389 if gname=="Lebanese Liberation Front"
replace gid=390 if gname=="Lebanese National Resistance Front"
replace gid=391 if gname=="Lebanese Socialist Revolutionary Organization"
replace gid=392 if gname=="Lehava"
replace gid=393 if gname=="Liberation Army for Presevo, Medvedja and Bujanovac (UCPMB)"
replace gid=394 if gname=="Liberation Tigers of Tamil Eelam (LTTE)"
replace gid=395 if gname=="Liberation and Justice Movement"
replace gid=396 if gname=="Liberation of Achik Elite Force "
replace gid=397 if gname=="Libya Revolutionaries Operations Room (LROR)"
replace gid=398 if gname=="Libya Shield Force"
replace gid=399 if gname=="Liwa al-Haqq"
replace gid=400 if gname=="Liwa al-Tawhid"
replace gid=401 if gname=="Lord's Resistance Army (LRA)"
replace gid=402 if gname=="Loyalist Volunteer Forces (LVF)"
replace gid=403 if gname=="M23"
replace gid=404 if gname=="Macina Liberation Front "
replace gid=405 if gname=="Madhesh Rastra Janatantrik Revolutionary"
replace gid=406 if gname=="Madhesi Mukti Tigers(MMT)"
replace gid=407 if gname=="Madhesi People's Rights Forum (MPRF)"
replace gid=408 if gname=="Madhesi Virus Killers"
replace gid=409 if gname=="Mahan Madhesh Janakantri Party "
replace gid=410 if gname=="Mahdi Army"
replace gid=411 if gname=="Mahir Cayan Suicide Group"
replace gid=412 if gname=="Manuel Rodriguez Patriotic Front (FPMR)"
replace gid=413 if gname=="Maoist Communist Center (MCC)"
replace gid=414 if gname=="Maoist Communist Party (MKP)"
replace gid=415 if gname=="Maoist Communist Party of Manipur"
replace gid=416 if gname=="Mariano Moreno National Liberation Commando"
replace gid=417 if gname=="Masada, Action and Defense Movement"
replace gid=418 if gname=="Mateo Morral Insurrectionist Commandos"
replace gid=419 if gname=="Maute Group"
replace gid=420 if gname=="Maximiliano Gomez Revolutionary Brigade"
replace gid=421 if gname=="May 15 Organization for the Liberation of Palestine"
replace gid=422 if gname=="May 19 Communist Order (U.S.)"
replace gid=423 if gname=="Meinhof-Puig-Antich Group"
replace gid=424 if gname=="Merille Militia"
replace gid=425 if gname=="Militant Forces Against Huntingdon"
replace gid=426 if gname=="Militant Minority (Greece)"
replace gid=427 if gname=="Militant Organization of Russian Nationalists"
replace gid=428 if gname=="Minutemen American Defense"
replace gid=429 if gname=="Misrata Brigades"
replace gid=430 if gname=="Mlada Bosna"
replace gid=431 if gname=="Mombasa Republican Council (MRC)"
replace gid=432 if gname=="Mongolian Mukti Morcha"
replace gid=433 if gname=="Montoneros (Argentina)"
replace gid=434 if gname=="Morazanist Front for the Liberation of Honduras"
replace gid=435 if gname=="Moro Islamic Liberation Front (MILF)"
replace gid=436 if gname=="Moro National Liberation Front (MNLF)"
replace gid=437 if gname=="Mouhajiroune Brigade"
replace gid=438 if gname=="Movement for Democracy and Development (MDD)"
replace gid=439 if gname=="Movement for Oneness and Jihad in West Africa"
replace gid=440 if gname=="Movement for the Emancipation of the Niger Delta"
replace gid=441 if gname=="Movement of Democratic Forces of Casamance"
replace gid=442 if gname=="Movement of Islamic Action of Iraq"
replace gid=443 if gname=="Movement of Niger People for Justice"
replace gid=444 if gname=="Movement of the Revolutionary Left (MIR) (Chile)"
replace gid=445 if gname=="Mozambique Liberation Front"
replace gid=446 if gname=="Mozambique National Resistance Movement (MNR)"
replace gid=447 if gname=="Mujahedeen Army"
replace gid=448 if gname=="Mujahedeen Corps in Iraq"
replace gid=449 if gname=="Mujahedeen Shura Council"
replace gid=450 if gname=="Mujahedeen Shura Council in the Environs of Jerusalem"
replace gid=451 if gname=="Mujahideen Ansar"
replace gid=452 if gname=="Mujahideen Youth Movement "
replace gid=453 if gname=="Mujahideen-I-Khalq"
replace gid=454 if gname=="Mujahidin Indonesia Timur (MIT)"
replace gid=455 if gname=="Mukhtar Army"
replace gid=456 if gname=="Mullah Dadullah Front"
replace gid=457 if gname=="Muslim Brotherhood"
replace gid=458 if gname=="Muslim United Army"
replace gid=459 if gname=="Muslim United Liberation Tigers of Assam"
replace gid=460 if gname=="Muslims Against Global Oppression"
replace gid=461 if gname=="Muttahida Qami Movement (MQM)"
replace gid=462 if gname=="Najd Province of the Islamic State"
replace gid=463 if gname=="National Anti-Corruption Front (FNA)"
replace gid=464 if gname=="National Army for the Liberation of Uganda"
replace gid=465 if gname=="National Committee for the Restoration of Democracy and State (CNRDR)"
replace gid=466 if gname=="National Congress for the Defense of the People"
replace gid=467 if gname=="National Democratic Alliance Army (NDAA-ESSA)"
replace gid=468 if gname=="National Democratic Front of Bodoland (Bhutan, Burma, India)"
replace gid=469 if gname=="National Freedom Party"
replace gid=470 if gname=="National Liberation Army of Colombia (ELN)"
replace gid=471 if gname=="National Liberation Army-Nepal"
replace gid=472 if gname=="National Liberation Front (FNL) (Burundi)"
replace gid=473 if gname=="National Liberation Front of Provence"
replace gid=474 if gname=="National Liberation Front of Tripura (NLFT)"
replace gid=475 if gname=="National Liberation Union"
replace gid=476 if gname=="National Patriotic Front of Liberia (NPFL)"
replace gid=477 if gname=="National Revolutionary Command (Umar al-Mukhtar)"
replace gid=478 if gname=="National Socialist Council of Nagaland-Isak-Muivah(NSCN-IM)"
replace gid=479 if gname=="National Socialist Council of Nagaland-Khaplang(NSCN-K) (Burma,India)"
replace gid=480 if gname=="National Union for the Total Independence of Angola"
replace gid=481 if gname=="National Youth Resistance Organization"
replace gid=482 if gname=="Nepal Defense Army"
replace gid=483 if gname=="Nestor Paz Zamora Commission (CNPZ)"
replace gid=484 if gname=="New Armenian Resistance"
replace gid=485 if gname=="New Irish Republican Army"
replace gid=486 if gname=="New People's Army (NPA)"
replace gid=487 if gname=="New Revolutionary Alternative"
replace gid=488 if gname=="Niger Delta Avengers"
replace gid=489 if gname=="Niger Delta Greenland Justice Mandate "
replace gid=490 if gname=="Niger Delta Liberation Force (NDLF)-Nigeria"
replace gid=491 if gname=="Niger Delta People's Volunteer Force"
replace gid=492 if gname=="Niger Delta Vigilante"
replace gid=493 if gname=="Nihilists Faction"
replace gid=494 if gname=="Ninth of June Organization"
replace gid=495 if gname=="Nordic Resistance Movement"
replace gid=496 if gname=="Nuclei Communist Combattants"
replace gid=497 if gname=="Nuer White Army"
replace gid=498 if gname=="Nur-al-Din al-Zinki Movement"
replace gid=499 if gname=="OPR-33"
replace gid=500 if gname=="October Third Movement"
replace gid=501 if gname=="Odua Peoples' Congress"
replace gid=502 if gname=="Ogaden National Liberation Front (ONLF)"
replace gid=503 if gname=="Okba Ibn Nafaa Brigade"
replace gid=504 if gname=="Omar Torrijos Commando for Latin American Dignity"
replace gid=505 if gname=="Omega-7 (U.S.)"
replace gid=506 if gname=="Orange Volunteers"
replace gid=507 if gname=="Orly Organization"
replace gid=508 if gname=="Oromo Liberation Front (OLF)"
replace gid=509 if gname=="Pakistani People's Party(PPP)"
replace gid=510 if gname=="Palestine Liberation Front (PLF)"
replace gid=511 if gname=="Palestine Liberation Organization (PLO)"
replace gid=512 if gname=="Palestinian Islamic Jihad (PIJ)"
replace gid=513 if gname=="Pan-Turkish Organization"
replace gid=514 if gname=="Paraguayan People's Army(EPP)"
replace gid=515 if gname=="Parbatya Chattagram Jana Sanghati Samity (PCJSS)"
replace gid=516 if gname=="Partido Marxista-Leninista ng Pilipinas (PMLP)"
replace gid=517 if gname=="Party for the Liberation of the Hutu People (PALIPEHUTU)"
replace gid=518 if gname=="Patriotic Europeans against the Islamization of the West"
replace gid=519 if gname=="Patriotic Resistance Front in Ituri (FRPI)"
replace gid=520 if gname=="Pattali Makkal Katchi (PMK)"
replace gid=521 if gname=="Pattani United Liberation Organization (PULO)"
replace gid=522 if gname=="Peace Conquerors"
replace gid=523 if gname=="Peace at Home Council"
replace gid=524 if gname=="Pedro Leon Arboleda (PLA)"
replace gid=525 if gname=="People Against Gangsterism and Drugs (PAGAD)"
replace gid=526 if gname=="People's Amn Committee"
replace gid=527 if gname=="People's Command"
replace gid=528 if gname=="People's Committee against Police Atrocities (PCPA)"
replace gid=529 if gname=="People's Liberation Army of Kurdistan (ARGK)"
replace gid=530 if gname=="People's Liberation Front of India"
replace gid=531 if gname=="People's Revolutionary Militias"
replace gid=532 if gname=="People's Revolutionary Organization"
replace gid=533 if gname=="People's Revolutionary Party (PRP)"
replace gid=534 if gname=="People's Revolutionary Party of Kangleipak (PREPAK)"
replace gid=535 if gname=="People's United Liberation Front"
replace gid=536 if gname=="People's War Group (PWG)"
replace gid=537 if gname=="Peoples' United Revolutionary Movement"
replace gid=538 if gname=="People�s Liberation Army (Bangladesh, Burma, India)"
replace gid=539 if gname=="People�s Liberation Forces (Colombia)"
replace gid=540 if gname=="Peronist Armed Forces (FAP)"
replace gid=541 if gname=="Peykar"
replace gid=542 if gname=="Polisario Front"
replace gid=543 if gname=="Polish Revolutionary Home Army"
replace gid=544 if gname=="Popular Forces of April 25"
replace gid=545 if gname=="Popular Front for Justice in the Congo"
replace gid=546 if gname=="Popular Front for Recovery (FPR)"
replace gid=547 if gname=="Popular Front for the Liberation of Palestine (PFLP)"
replace gid=548 if gname=="Popular Front for the Liberation of Palestine-General Command (PFLP-GC)"
replace gid=549 if gname=="Popular Liberation Army (EPL)"
replace gid=550 if gname=="Popular Mobilization Forces (Iraq)"
replace gid=551 if gname=="Popular Movement for the Liberation of Angola"
replace gid=552 if gname=="Popular Resistance Committees"
replace gid=553 if gname=="Popular Resistance Committees(Yemen)"
replace gid=554 if gname=="Popular Resistance Movement"
replace gid=555 if gname=="Popular Revolutionary Action"
replace gid=556 if gname=="Popular Revolutionary Army"
replace gid=557 if gname=="Popular Revolutionary Resistance Group"
replace gid=558 if gname=="Popular Revolutionary Vanguard (VPR)"
replace gid=559 if gname=="Proletarian Action Group/Proletarian Combatant Groups (Italy)"
replace gid=560 if gname=="Proletarian Nuclei for Communism"
replace gid=561 if gname=="Provisional RSPCA"
replace gid=562 if gname=="Puerto Rican Resistance Movement"
replace gid=563 if gname=="Purbo Banglar Communist Party (PBCP)"
replace gid=564 if gname=="Qari Kamran Group"
replace gid=565 if gname=="Rabha National Security Force"
replace gid=566 if gname=="Rafallah al-Sahati Brigade"
replace gid=567 if gname=="Ranbir Sena"
replace gid=568 if gname=="Rashtriya Swayamsevak Sangh"
replace gid=569 if gname=="Raskamboni Movement"
replace gid=570 if gname=="Rastriya Janashakti Party "
replace gid=571 if gname=="Raul Sendic International Brigade"
replace gid=572 if gname=="Real Irish Republican Army (RIRA)"
replace gid=573 if gname=="Real Ulster Freedom Fighters (UFF) - Northern Ireland"
replace gid=574 if gname=="Rebel Armed Forces (Guatemala)"
replace gid=575 if gname=="Rebellious Group Lambros Foundas"
replace gid=576 if gname=="Recontras"
replace gid=577 if gname=="Red Army Faction (RAF)"
replace gid=578 if gname=="Red Brigades"
replace gid=579 if gname=="Red Egbesu Water Lions"
replace gid=580 if gname=="Red Flag (Venezuela)"
replace gid=581 if gname=="Red Guerrillas"
replace gid=582 if gname=="Red Hand Defenders"
replace gid=583 if gname=="Red Scorpion"
replace gid=584 if gname=="Red Sea Afar Democratic Organization"
replace gid=585 if gname=="Republic of New Africa"
replace gid=586 if gname=="Republican Action Against Drugs"
replace gid=587 if gname=="Resistencia Galega"
replace gid=588 if gname=="Resistenza Corsa"
replace gid=589 if gname=="Return, Reclamation, Rehabilitation (3R)"
replace gid=590 if gname=="Revolutionaries Army (Jaysh al-Thowwar)"
replace gid=591 if gname=="Revolutionary Action Party"
replace gid=592 if gname=="Revolutionary Armed Forces of Colombia (FARC)"
replace gid=593 if gname=="Revolutionary Autonomous Group"
replace gid=594 if gname=="Revolutionary Cells(Argentina)"
replace gid=595 if gname=="Revolutionary Cells-Animal Liberation Brigade"
replace gid=596 if gname=="Revolutionary Eelam Organization (EROS)"
replace gid=597 if gname=="Revolutionary Force Seven"
replace gid=598 if gname=="Revolutionary Front for Communism"
replace gid=599 if gname=="Revolutionary Headquarters (Turkey)"
replace gid=600 if gname=="Revolutionary Insurgent Armed Forces of Ecuador (FAIRE)"
replace gid=601 if gname=="Revolutionary Leninist Brigades"
replace gid=602 if gname=="Revolutionary Movement for National Salvation(REMNASA)"
replace gid=603 if gname=="Revolutionary Nuclei"
replace gid=604 if gname=="Revolutionary Organization of Socialist Moslems"
replace gid=605 if gname=="Revolutionary People's Struggle (ELA)"
replace gid=606 if gname=="Revolutionary Perspective"
replace gid=607 if gname=="Revolutionary Proletarian Initiative Nuclei (NIPR)"
replace gid=608 if gname=="Revolutionary Struggle"
replace gid=609 if gname=="Revolutionary United Front (RUF)"
replace gid=610 if gname=="Revolutionary Worker Clandestine Union of the People Party"
replace gid=611 if gname=="Right Sector"
replace gid=612 if gname=="Riyad us-Saliheyn Martyrs' Brigade"
replace gid=613 if gname=="Rohingya Solidarity Organization"
replace gid=614 if gname=="Runda Kumpulan Kecil (RKK)"
replace gid=615 if gname=="Russian Unity"
replace gid=616 if gname=="Sabaot Land Defense Force"
replace gid=617 if gname=="Saif-ul-Muslimeen"
replace gid=618 if gname=="Salafia Jihadia"
replace gid=619 if gname=="Salafist Group for Preaching and Fighting (GSPC)"
replace gid=620 if gname=="Samyukta Jatiya Mukti Morcha"
replace gid=621 if gname=="Samyukta Terai Madhes Mukti Party"
replace gid=622 if gname=="Sanaa Province of the Islamic State"
replace gid=623 if gname=="Saraya al-Mukhtar"
replace gid=624 if gname=="Sardinian Autonomy Movement (MAS)"
replace gid=625 if gname=="Save Kashmir Movement"
replace gid=626 if gname=="Secret Army Organization"
replace gid=627 if gname=="Secret Organization Zero"
replace gid=628 if gname=="Sect of Revolutionaries"
replace gid=629 if gname=="Shabelle Valley militia"
replace gid=630 if gname=="Shahin (Falcon)"
replace gid=631 if gname=="Shamiya Front"
replace gid=632 if gname=="Shan State Army - North (SSA-N)"
replace gid=633 if gname=="Shan State Army - South (SSA-S)"
replace gid=634 if gname=="Sheikh Omar Hadid Brigade"
replace gid=635 if gname=="Shield of Islam Brigade"
replace gid=636 if gname=="Shining Path"
replace gid=637 if gname=="Shiv Sena"
replace gid=638 if gname=="Shura Council of Benghazi Revolutionaries"
replace gid=639 if gname=="Shura Council of Mujahideen in Derna"
replace gid=640 if gname=="Simon Bolivar Guerilla Coordinating Board (CGSB)"
replace gid=641 if gname=="Sinai Province of the Islamic State"
replace gid=642 if gname=="Sindhu Desh Liberation Army"
replace gid=643 if gname=="Sipah-I-Mohammed"
replace gid=644 if gname=="Sipah-e-Sahaba Pakistan"
replace gid=645 if gname=="Sons of the South"
replace gid=646 if gname=="South Londonderry Volunteers"
replace gid=647 if gname=="South Sudan Liberation Army (SSLA)"
replace gid=648 if gname=="South-West Africa People's Organization (SWAPO)"
replace gid=649 if gname=="Southern Front"
replace gid=650 if gname=="Southern Mobility Movement (Yemen)"
replace gid=651 if gname=="Sovereign Citizen"
replace gid=652 if gname=="Spanish Basque Battalion (BBE) (rightist)"
replace gid=653 if gname=="Spanish National Action"
replace gid=654 if gname=="Students Islamic Movement of India (SIMI)"
replace gid=655 if gname=="Sudan Liberation Army-Minni Minawi (SLA-MM)"
replace gid=656 if gname=="Sudan Liberation Movement"
replace gid=657 if gname=="Sudan People's Liberation Army (SPLA)"
replace gid=658 if gname=="Sudan People's Liberation Movement - North"
replace gid=659 if gname=="Sudan People's Liberation Movement in Opposition (SPLM-IO)"
replace gid=660 if gname=="Sudan Revolutionary Front (SRF)"
replace gid=661 if gname=="Supreme Command for Jihad and Liberation"
replace gid=662 if gname=="Swatantra Nepal Dal"
replace gid=663 if gname=="Syrian Democratic Forces (SDF)"
replace gid=664 if gname=="Syrian Mujahideen"
replace gid=665 if gname=="Syrian Social Nationalist Party"
replace gid=666 if gname=="Syrian Turkmen Brigades"
replace gid=667 if gname=="Ta'ang National Liberation Army (TNLA) "
replace gid=668 if gname=="Takfir wa Hijra"
replace gid=669 if gname=="Taliban"
replace gid=670 if gname=="Tamil Makkal Viduthalai Pulikal (TMVP)"
replace gid=671 if gname=="Tamil Nadu Liberation Army"
replace gid=672 if gname=="Tanzim"
replace gid=673 if gname=="Tawhid and Jihad"
replace gid=674 if gname=="Tehrik al-Mojahedin"
replace gid=675 if gname=="Tehrik-e-Galba Islam"
replace gid=676 if gname=="Tehrik-e-Hurriyat"
replace gid=677 if gname=="Tehrik-e-Nafaz-e-Shariat-e-Mohammadi (TNSM)"
replace gid=678 if gname=="Tehrik-e-Tuhafaz (Pakistan)"
replace gid=679 if gname=="Tehrik-i-Taliban Pakistan(TTP)"
replace gid=680 if gname=="Terai Army"
replace gid=681 if gname=="Terai Cobra"
replace gid=682 if gname=="Terai Madheshi Mukti Morcha (TMMM)"
replace gid=683 if gname=="Terai Rastriya Mukti Sena (TRMS)"
replace gid=684 if gname=="Terra Lliure"
replace gid=685 if gname=="Thanthai Periyar Dravidar Kazhagam"
replace gid=686 if gname=="Tharuhat Joint Struggle Committee"
replace gid=687 if gname=="The Association for Islamic Mobilisation and Propagation (UAMSHO)"
replace gid=688 if gname=="The Inevitables"
replace gid=689 if gname=="The Irish Volunteers"
replace gid=690 if gname=="The Jean Marc Rouillan Armed and Heartless Columns"
replace gid=691 if gname=="The Joint Revolutionary Council"
replace gid=692 if gname=="The Third Way (Der III. Weg)"
replace gid=693 if gname=="The United Revolutionary Front of Bhutan"
replace gid=694 if gname=="Tigray Peoples Liberation Front (TPLF)"
replace gid=695 if gname=="Tripoli Province of the Islamic State"
replace gid=696 if gname=="Tritiya Prastuti Committee"
replace gid=697 if gname=="Tupac Amaru Revolutionary Movement (MRTA)"
replace gid=698 if gname=="Tupac Katari Guerrilla Army (EGTK)"
replace gid=699 if gname=="Tupamaros (Uruguay)"
replace gid=700 if gname=="Turkish Communist Party/Marxist (TKP-ML)"
replace gid=701 if gname=="Turkish Hizballah"
replace gid=702 if gname=="Turkish People's Liberation Army"
replace gid=703 if gname=="Turkish People's Liberation Front (TPLF)(THKP-C)"
replace gid=704 if gname=="Uganda Democratic Christian Army (UDCA)"
replace gid=705 if gname=="Ukrainian Insurgent Army"
replace gid=706 if gname=="Ulster Defence Association/Ulster Freedom Fighters"
replace gid=707 if gname=="Ulster Volunteer Force (UVF)"
replace gid=708 if gname=="Ummah Liberation Army"
replace gid=709 if gname=="Union for Peace in Central Africa"
replace gid=710 if gname=="Union of Congolese Patriots (UPC)"
replace gid=711 if gname=="Union of Forces for Democracy and Development"
replace gid=712 if gname=="United Arab Revolution"
replace gid=713 if gname=="United Baloch Army"
replace gid=714 if gname=="United Bengali Liberation Front"
replace gid=715 if gname=="United Democratic Liberation Army (UDLA)"
replace gid=716 if gname=="United Democratic Madhesi Front"
replace gid=717 if gname=="United Democratic Terai Liberation Front "
replace gid=718 if gname=="United Freedom Front (UFF)"
replace gid=719 if gname=="United Front for Democracy Against Dictatorship"
replace gid=720 if gname=="United Jihad Council"
replace gid=721 if gname=="United Kuki Liberation Front (UKLF) "
replace gid=722 if gname=="United Liberation Front of Assam (ULFA)"
replace gid=723 if gname=="United Liberation Front of Barak Valley (ULFBV) India"
replace gid=724 if gname=="United National Liberation Front (UNLF)"
replace gid=725 if gname=="United People's Democratic Front (UPDF) - Bangladesh"
replace gid=726 if gname=="United People's Democratic Solidarity (UPDS)"
replace gid=727 if gname=="United Popular Action Movement"
replace gid=728 if gname=="United Revolutionary Front"
replace gid=729 if gname=="United Self Defense Forces of Colombia (AUC)"
replace gid=730 if gname=="Up the IRS, Inc. (U.S.)"
replace gid=731 if gname=="Urhobo Revolutionary Army"
replace gid=732 if gname=="Vandalicia Teodoro Suarez"
replace gid=733 if gname=="Venceremos"
replace gid=734 if gname=="Vetevendosje"
replace gid=735 if gname=="Vishwa Hindu Parishad "
replace gid=736 if gname=="Weather Underground, Weathermen"
replace gid=737 if gname=="West Nile Bank Front (WNBF)"
replace gid=738 if gname=="White Legion"
replace gid=739 if gname=="Workers' Revolutionary Party"
replace gid=740 if gname=="Yakariya Bango Insurgent Group"
replace gid=741 if gname=="Yarmouk Martyrs Brigade"
replace gid=742 if gname=="Young Communist League"
replace gid=743 if gname=="Young Liberators of Pattani"
replace gid=744 if gname=="Youth Action Group"
replace gid=745 if gname=="Zapatista National Liberation Army"
replace gid=746 if gname=="Zarate Willka Armed Forces of Liberation"
replace gid=747 if gname=="Zeliangrong United Front"
replace gid=748 if gname=="Zero Tolerance"
replace gid=749 if gname=="Zimbabwe African Nationalist Union (ZANU)"
replace gid=750 if gname=="Zomi Revolutionary Army (ZRA)"
replace gid=751 if gname=="Zuwar al-Imam Rida"
replace gid=752 if gname=="al Qaeda in the Arabian Peninsula (AQAP)"
replace gid=753 if gname=="al-Badr"
replace gid=754 if gname=="al-Fatah"
replace gid=755 if gname=="al-Gama'at al-Islamiyya (IG)"
replace gid=756 if gname=="al-Haramayn Brigades"
replace gid=757 if gname=="al-Intiqami al-Pakistani"
replace gid=758 if gname=="al-Ittihaad al-Islami"
replace gid=759 if gname=="al-Madina"
replace gid=760 if gname=="al-Qaeda"
   replace gid=1012 if gname=="Ansar al-Sharia (Tunisia)"
 replace gid=1014 if gname=="Ansaru (Jama'atu Ansarul Muslimina Fi Biladis Sudan)"
 replace gid=1031 if gname=="Hezbollah Palestine"
 replace gid=1037 if gname=="Islamic Jihad Union (Uzbekistan)"
 replace gid=1060 if gname=="November 17 Revolutionary Organization (N17RO)"
 
 drop if gid==.

gen gnumb=.

replace gnumb=1 if gname=="Abdullah Azzam Brigades"
replace gnumb=2 if gname=="Abu Nidal Organization (ANO)"
replace gnumb=3 if gname=="Abu Sayyaf Group (ASG)"
 
replace gnumb=4 if gname=="al-Qaeda"
replace gnumb=5 if gname=="Al-Qaida in the Indian Subcontinent"
replace gnumb=6 if gname=="Al-Aqsa Martyrs Brigade"
replace gnumb=7 if gname=="Al-Nusrah Front"
replace gnumb=8 if gname=="Al-Shabaab"

replace gnumb=9 if gname=="Ansar al-Dine"
replace gnumb=9 if gname=="Ansar al-Dine (Mali)"

replace gnumb=10 if gname=="Ansar al-Islam"
replace gnumb=11 if gname=="Ansar al-Sharia (Libya)"
replace gnumb=12 if gname=="Ansar al-Sharia (Tunisia)"
replace gnumb=13 if gname=="Ansaru (Jama'atu Ansarul Muslimina Fi Biladis Sudan)"
replace gnumb=14 if gname=="Al-Qaida in the Arabian Peninsula (AQAP)"

replace gnumb=15 if gname=="Al-Qaida in the Islamic Maghreb (AQIM)"
replace gnumb=16 if gname=="Armed Islamic Group (GIA)"
replace gnumb=17 if gname=="Army of Islam"
replace gnumb=18 if gname=="Asbat al-Ansar"

replace gnumb=19 if gname=="Aum ShinriKyo"
replace gnumb=20 if gname=="Basque Fatherland and Freedom (ETA)"
replace gnumb=21 if gname=="Boko Haram"
replace gnumb=22 if gname=="Continuity Irish Republican Army (CIRA)"
replace gnumb=23 if gname=="New People's Army (NPA)"
 
replace gnumb=24 if gname=="Democratic Front for the Liberation of Palestine"
replace gnumb=25 if gname=="Revolutionary Armed Forces of Colombia (FARC)"

replace gnumb=26 if gname=="al-Gama'at al-Islamiyya (IG)"
 
replace gnumb=27 if gname=="Hamas"
replace gnumb=28 if gname=="Haqqani Network"
replace gnumb=29 if gname=="Harkatul Jihad-e-Islami"
 
replace gnumb=30 if gname=="Harkat ul-Mujahedin"
 
replace gnumb=31 if gname=="Hezbollah Palestine"
replace gnumb=32 if gname=="Indian Mujahideen"

replace gnumb=33 if gname=="Al-Qaida in Iraq"
replace gnumb=33 if gname=="Islamic State of Iraq and the Levant (ISIL)"
replace gnumb=33 if gname=="Islamic State of Iraq (ISI)"
replace gnumb=34 if gname=="Ansar Bayt al-Maqdis (Ansar Jerusalem)"
replace gnumb=35 if gname=="Khorasan Chapter of the Islamic State"
*******
replace gnumb=36 if gname=="Hizbul Mujahideen (HM)"
********
replace gnumb=37 if gname=="Islamic Jihad Union (Uzbekistan)"

replace gnumb=38 if gname=="Islamic Movement of Uzbekistan"
replace gnumb=39 if gname=="Jaish-e-Mohammad (JeM)"
replace gnumb=40 if gname=="Japanese Red Army (JRA)"
replace gnumb=41 if gname=="Jamaah Ansharut Tauhid (JAT)"
replace gnumb=42 if gname=="Jemaah Islamiya (JI)"

replace gnumb=43 if gname=="Jundallah (Iran)"
replace gnumb=43 if gname=="Jundallah (Pakistan)"
replace gnumb=44 if gname=="Kahane Chai"
replace gnumb=45 if gname=="Khmer Rouge"

replace gnumb=46 if gname=="Kurdistan Workers Party(PKK)"
replace gnumb=47 if gname=="Lashkar-e-Jhangvi"
replace gnumb=48 if gname=="Lashkar-e-Taiba (LeT)"
replace gnumb=49 if gname=="Liberation Tigers of Tamil Eelam (LTTE)"
replace gnumb=50 if gname=="Manuel Rodriguez Patriotic Front (FPMR)"

replace gnumb=51 if gname=="Mujahideen-I-Khalq"
replace gnumb=52 if gname=="Mujahedeen Shura Council in the Environs of Jerusalem"
replace gnumb=53 if gname=="National Liberation Army of Colombia (ELN)"
replace gnumb=54 if gname=="Palestine Liberation Front (PLF)"
replace gnumb=55 if gname=="Palestinian Islamic Jihad (PIJ)"
replace gnumb=56 if gname=="Popular Front for the Liberation of Palestine (PFLP)"


replace gnumb=57 if gname=="Popular Front for the Liberation of Palestine-General Command (PFLP-GC)"
replace gnumb=58 if gname=="Real Irish Republican Army (RIRA)"
replace gnumb=59 if gname=="Revolutionary Nuclei"
replace gnumb=60 if gname=="November 17 Revolutionary Organization (N17RO)"
replace gnumb=61 if gname=="Devrimici Halk Kurtulus Cephesi (DHKP/C)"
replace gnumb=62 if gname=="Revolutionary Struggle"

replace gnumb=63 if gname=="Shining Path"

replace gnumb=64 if gname=="Tehrik-i-Taliban Pakistan(TTP)"
replace gnumb=65 if gname=="Tupac Amaru Revolutionary Movement (MRTA)"

replace gnumb=66 if gname=="United Self Defense Forces of Colombia (AUC)"
***
replace gnumb=67 if gname== "Libya Shield Force"
replace gnumb=68 if gname=="Kata'ib Hezbollah"



set more off 

gen dateuncertain1=.
gen dateuncertain2=.
replace dateuncertain1=1 if imonth==0 
replace dateuncertain2=1 if iday==0
replace imonth=1 if imonth==0
replace iday=1 if iday==0

rename iyear year
rename imonth month
rename iday day
gen edate = mdy(month, day, year)
format year %ty


gen listdate=.
replace listdate=mdy(05,30,2012) if gnumb==1
replace listdate=mdy(10, 08,1997) if gnumb==2
replace listdate=mdy(10, 08,1997) if gnumb==3
replace listdate=mdy(10, 08,1999) if gnumb==4
replace listdate=mdy(07, 01,2016) if gnumb==5
replace listdate=mdy(03, 27,2002) if gnumb==6
replace listdate=mdy(05, 15,2014) if gnumb==7
replace listdate=mdy(03, 18,2008) if gnumb==8
replace listdate=mdy(03, 22,2013) if gnumb==9
replace listdate=mdy(03, 22,2004) if gnumb==10
replace listdate=mdy(01, 13,2014) if gnumb==11
replace listdate=mdy(01, 13,2014) if gnumb==12
replace listdate=mdy(11, 14,2013) if gnumb==13
replace listdate=mdy(01, 19,2010) if gnumb==14
replace listdate=mdy(03, 27,2002) if gnumb==15
replace listdate=mdy(10, 08,1997) if gnumb==16
replace listdate=mdy(05, 23,2011) if gnumb==17
replace listdate=mdy(03, 27,2002) if gnumb==18
replace listdate=mdy(10, 08,1997) if gnumb==19
replace listdate=mdy(10, 08,1997) if gnumb==20
replace listdate=mdy(11, 14,2013) if gnumb==21
replace listdate=mdy(07, 13,2004) if gnumb==22
replace listdate=mdy(08, 09,2002) if gnumb==23
replace listdate=mdy(10, 08,1997) if gnumb==24
replace listdate=mdy(10, 08,1997) if gnumb==25
replace listdate=mdy(10, 08,1997) if gnumb==26
replace listdate=mdy(10, 08,1997) if gnumb==27
replace listdate=mdy(09, 19,2012) if gnumb==28
replace listdate=mdy(08, 06,2010) if gnumb==29
replace listdate=mdy(10, 08,1997) if gnumb==30
replace listdate=mdy(10, 08,1997) if gnumb==31
replace listdate=mdy(09, 19,2011) if gnumb==32
replace listdate=mdy(12, 17,2004) if gnumb==33
replace listdate=mdy(04, 10,2014) if gnumb==34
replace listdate=mdy(01, 14,2016) if gnumb==35
replace listdate=mdy(08, 17,2017) if gnumb==36
replace listdate=mdy(06, 17,2005) if gnumb==37
replace listdate=mdy(09, 25,2000) if gnumb==38
replace listdate=mdy(12, 26,2001) if gnumb==39
replace listdate=mdy(10, 08,1997) if gnumb==40
replace listdate=mdy(03, 13,2012) if gnumb==41
replace listdate=mdy(10, 23,2002) if gnumb==42
replace listdate=mdy(11, 04,2010) if gnumb==43
replace listdate=mdy(10, 08,1997) if gnumb==44
replace listdate=mdy(10, 08,1997) if gnumb==45
replace listdate=mdy(10, 08,1997) if gnumb==46
replace listdate=mdy(01, 30,2003) if gnumb==47
replace listdate=mdy(12, 26,2001) if gnumb==48
replace listdate=mdy(10, 08,1997) if gnumb==49
replace listdate=mdy(10, 08,1997) if gnumb==50
replace listdate=mdy(10, 08,1997) if gnumb==51
replace listdate=mdy(08, 20,2014) if gnumb==52
replace listdate=mdy(10, 08,1997) if gnumb==53
replace listdate=mdy(10, 08,1997) if gnumb==54
replace listdate=mdy(10, 08,1997) if gnumb==55
replace listdate=mdy(10, 08,1997) if gnumb==56
replace listdate=mdy(10, 08,1997) if gnumb==57
replace listdate=mdy(05, 16,2001) if gnumb==58
replace listdate=mdy(10, 08,1997) if gnumb==59
replace listdate=mdy(10, 08,1997) if gnumb==60
replace listdate=mdy(10, 08,1997) if gnumb==61
replace listdate=mdy(05, 18,2009) if gnumb==62
replace listdate=mdy(10, 08,1997) if gnumb==63
replace listdate=mdy(09, 01,2010) if gnumb==64
replace listdate=mdy(10, 08,1997) if gnumb==65
replace listdate=mdy(09, 10,2001) if gnumb==66
replace listdate=mdy(12, 17,2004) if gnumb==67
replace listdate=mdy(07, 02,2009) if gnumb==68

gen enddate=mdy(12,31,2017)
replace enddate=mdy(10,15,2010) if gnumb==16
replace enddate=mdy(10,08,1999) if gnumb==24
replace enddate=mdy(10,08,2001) if gnumb==40
replace enddate=mdy(10,08,1999) if gnumb==45
replace enddate=mdy(10,08,1999) if gnumb==50
replace enddate=mdy(09,28,2012) if gnumb==51
replace enddate=mdy(05,18,2009) if gnumb==59
replace enddate=mdy(09,03,2015) if gnumb==60
replace enddate=mdy(10,08,2001) if gnumb==65
replace enddate=mdy(07,15,2014) if gnumb==66
replace enddate=mdy(12,09,2015) if gnumb==67
*DFLP (gnumb==24) carries out 20 attacks after its removal from the list. The GTD records no activity for the group in the years 1995-2000. "The Manuel Rodriguez Patriotic Front Dissidents (FPMR/D) and the Democratic Front for the Liberation of Palestine (DFLP)* were dropped primarily because of the absence of terrorist activity, as defined by relevant law, by those groups during the past two years.... * The DFLP is still subject to the provisions of an Executive Order signed by President Clinton in January 1995 aimed at terrorist groups that threaten to disrupt the Middle East peace process. The Executive Order prohibits financial transactions with these terrorist groups and blocks their assets in the United States." https://www.state.gov/j/ct/rls/rpt/fto/2682.htm

format listdate %d
format enddate %d


gen listyear=year(listdate)
format listyear %ty
gen eyear=year(edate)
format eyear %ty
gen endyear=year(enddate)
format endyear %ty

gen date=mdy(month,day,year)
format date %d


bys gid year: egen yearlytotal=count(eventid)
**generates a variable that takes the value of the number of attacks by the same group in the same month

bys gid year: egen yearlykill=total(nkill)
bys year: egen yearlykillall=total(nkill)


gen lethal=.
replace lethal=1 if nkill>0
replace lethal=0 if nkill==0
replace lethal=1 if nkill==-99
replace lethal =0 if nkill == . 
**the -99 code is not used in this subset of the data
gen killwound=0
replace killwound=1 if lethal==1|nwound>0 & nwound != .

by gid year, sort: egen pclethal = mean(100 * lethal)

by gid year, sort: egen pckillwound = mean(100 * killwound)


gen civtarg=0
replace civtarg=1 if targtype1==1 // business
replace civtarg=1 if targtype1==8 //educational institution
replace civtarg=1 if targtype1==10 //journalists&media
replace civtarg=1 if targtype1==14 //private citizens&property
replace civtarg=1 if targtype1==15 //relig figures/institutions
replace civtarg=1 if targtype1==18 //tourists

replace civtarg=1 if targtype2==1
replace civtarg=1 if targtype2==8
replace civtarg=1 if targtype2==10
replace civtarg=1 if targtype2==14
replace civtarg=1 if targtype2==15
replace civtarg=1 if targtype2==18

replace civtarg=1 if targtype3==1
replace civtarg=1 if targtype3==8
replace civtarg=1 if targtype3==10
replace civtarg=1 if targtype3==14
replace civtarg=1 if targtype3==15
replace civtarg=1 if targtype3==18

gen govmiltarg=0
replace govmiltarg=1 if targtype1==2 //govt(general)
replace govmiltarg=1 if targtype1==3 //*police
replace govmiltarg=1 if targtype1==4 //miliary

replace govmiltarg=1 if targtype2==2
replace govmiltarg=1 if targtype2==3
replace govmiltarg=1 if targtype2==4

replace govmiltarg=1 if targtype3==2
replace govmiltarg=1 if targtype3==3
replace govmiltarg=1 if targtype3==4

gen NSAtarg=0
replace NSAtarg=1 if targtype1==17
replace NSAtarg=1 if targtype1==22

replace NSAtarg=1 if targtype2==17
replace NSAtarg=1 if targtype2==22

replace NSAtarg=1 if targtype3==17
replace NSAtarg=1 if targtype3==22

gen hicapmode = 0
replace hicapmode=1 if attacktype1==1
replace hicapmode=1 if attacktype1==4
replace hicapmode=1 if attacktype1==6
replace hicapmode=1 if attacktype1==5


 gen kidnap=.
 replace kidnap=1 if attacktype1==6
 replace kidnap=1 if attacktype2==6
 replace kidnap=1 if attacktype3==6 


gen fto=1
replace fto=0 if gnumb==.

 collapse (sum) sumkidnap=kidnap killtotal=nkill sumhicap=hicapmode sumcivtarg=civtarg sumgovmiltarg= govmiltarg  (mean) fto avgkill=nkill gid avgkillwound=killwound pckillwound pclethal attacks=yearlytotal (max) hicap=hicapmode maxkill=nkill gnumb (count) eventid lethal nkillwound=killwound countcivtarg=civtarg countgovmiltarg= govmiltarg countNSAtarg= NSAtarg, by(gname year)
  *previous line produced gnumb moyr panel data. Note that listtemp is coded 1 for the month of listing. 

  
 
   tsset gid year
    

 joinby gid year using EDTG_tomerge.dta, unmatched(master)

 tab _merge
 tab fto _merge
drop if fto==0 & _merge==1

gen pccivtarg = sumcivtarg/attacks
gen pcgovmiltarg = sumgovmiltarg/attacks

gen pchicapmode = sumhicap/attacks

set more off
drop sumcivtarg sumgovmiltarg  pclethal maxkill eventid lethal nkillwound countcivtarg countgovmiltarg countNSAtarg

drop if year > 2017
drop if year < 1980
bysort gid : gen order =_n
by gid: gen last = _n ==_N
expand 2 if last, generate(endyear)
drop last

replace attacks=0 if endyear==1
replace hicap=0 if endyear==1
replace killtotal=0 if endyear==1
replace pccivtarg=. if endyear==1
replace pcgovmiltarg=. if endyear==1
replace avgkill=. if endyear==1
replace avgkillwound=. if endyear==1
replace pckillwound=. if endyear==1
replace num_base=. if endyear==1
replace mul_bases=. if endyear==1
replace shr_trans=. if endyear==1
replace endstr=. if endyear==1 & endstr==0
replace endstr=. if endyear==1 & endstr==5
replace terrctrl=. if endyear==1
replace state_sponsor=. if endyear==1
replace num_sponsor=. if endyear==1
replace social_service=. if endyear==1
replace num_allies=. if endyear==1
replace num_rivals=. if endyear==1
replace num_enemies=. if endyear==1
replace fate_leader=. if endyear==1
replace sumkidnap=0 if endyear==1
replace duration=. if endyear==1
replace end=. if endyear==1
replace diversity=. if endyear==1
replace kidnap=. if endyear==1
replace total_deaths=. if endyear==1
replace pchicapmode=. if endyear==1
replace order=. if endyear==1


drop terr_POP total_atks total_casualties 
*******
drop if year==2017 & endyear==1


replace year=2017 if endyear==1
gen year_num = year

tsfill 

*change new . to 0
replace killtotal=0 if killtotal==.
replace attacks=0 if attacks==.
replace hicap=0 if hicap==. & attacks==.
replace sumkidnap=0 if sumkidnap==.
replace sumhicap=0 if sumhicap==.
replace hicap=0 if hicap==.
 

set more off
bysort gid (year): carryforward gname fto gnumb MENA left nat rel right ercsr nat pch sq tch, replace

gen negyr = -year

bysort gid (negyr): carryforward gname fto gnumb MENA left nat rel right ercsr nat pch sq tch, replace
drop negyr


gen startyear=.
format startyear %ty

replace startyear=year-duration
bysort gid (year): carryforward startyear, replace

** the following fills in values of startyear where group not in etdg or for observations prior to first obs in etdg
replace startyear=2011 if gid==1014
*EDTG records activity in 2011, but CTC report indicates its formation was announced in January of 2012 https://ctc.usma.edu/leadership-analysis-of-boko-haram-and-ansaru-in-nigeria/ 
replace startyear=2013 if gid==45
replace startyear=2005 if gid==46
replace startyear=2011 if gid==77
replace startyear=2010 if gid==117
replace startyear=2003 if gid==302
replace startyear=1988 if gid==412
replace startyear=2002 if gid==608
replace startyear=1992 if gid==755
replace startyear=2011 if gnumb==12
*prev 1 from state dept
replace startyear=2003 if gnumb==14
*BAAD
replace startyear=1981 if gnumb==31
*BAAD
replace startyear=2002 if gnumb==37
*https://www.swp-berlin.org/en/publication/the-islamic-jihad-union/
replace startyear=1974 if gnumb==60
*BAAD


format startyear %ty

tsset

 
gen GTDolder =.
replace GTDolder=1 if startyear>year

bysort gid (year): carryforward startyear, replace



 gen age = year - startyear
replace age=0 if age <=0


xtset gid year
****




format year_num %10.0g


gen listdate=.
replace listdate=mdy(05,30,2012) if gnumb==1
replace listdate=mdy(10, 08,1997) if gnumb==2
replace listdate=mdy(10, 08,1997) if gnumb==3
replace listdate=mdy(10, 08,1999) if gnumb==4
replace listdate=mdy(07, 01,2016) if gnumb==5
replace listdate=mdy(03, 27,2002) if gnumb==6
replace listdate=mdy(05, 15,2014) if gnumb==7
replace listdate=mdy(03, 18,2008) if gnumb==8
replace listdate=mdy(03, 22,2013) if gnumb==9
replace listdate=mdy(03, 22,2004) if gnumb==10
replace listdate=mdy(01, 13,2014) if gnumb==11
replace listdate=mdy(01, 13,2014) if gnumb==12
replace listdate=mdy(11, 14,2013) if gnumb==13
replace listdate=mdy(01, 19,2010) if gnumb==14
replace listdate=mdy(03, 27,2002) if gnumb==15
replace listdate=mdy(10, 08,1997) if gnumb==16
replace listdate=mdy(05, 23,2011) if gnumb==17
replace listdate=mdy(03, 27,2002) if gnumb==18
replace listdate=mdy(10, 08,1997) if gnumb==19
replace listdate=mdy(10, 08,1997) if gnumb==20
replace listdate=mdy(11, 14,2013) if gnumb==21
replace listdate=mdy(07, 13,2004) if gnumb==22
replace listdate=mdy(08, 09,2002) if gnumb==23
replace listdate=mdy(10, 08,1997) if gnumb==24
replace listdate=mdy(10, 08,1997) if gnumb==25
replace listdate=mdy(10, 08,1997) if gnumb==26
replace listdate=mdy(10, 08,1997) if gnumb==27
replace listdate=mdy(09, 19,2012) if gnumb==28
replace listdate=mdy(08, 06,2010) if gnumb==29
replace listdate=mdy(10, 08,1997) if gnumb==30
replace listdate=mdy(10, 08,1997) if gnumb==31
replace listdate=mdy(09, 19,2011) if gnumb==32
replace listdate=mdy(12, 17,2004) if gnumb==33
replace listdate=mdy(04, 10,2014) if gnumb==34
replace listdate=mdy(01, 14,2016) if gnumb==35
replace listdate=mdy(08, 17,2017) if gnumb==36
replace listdate=mdy(06, 17,2005) if gnumb==37
replace listdate=mdy(09, 25,2000) if gnumb==38
replace listdate=mdy(12, 26,2001) if gnumb==39
replace listdate=mdy(10, 08,1997) if gnumb==40
replace listdate=mdy(03, 13,2012) if gnumb==41
replace listdate=mdy(10, 23,2002) if gnumb==42
replace listdate=mdy(11, 04,2010) if gnumb==43
replace listdate=mdy(10, 08,1997) if gnumb==44
replace listdate=mdy(10, 08,1997) if gnumb==45
replace listdate=mdy(10, 08,1997) if gnumb==46
replace listdate=mdy(01, 30,2003) if gnumb==47
replace listdate=mdy(12, 26,2001) if gnumb==48
replace listdate=mdy(10, 08,1997) if gnumb==49
replace listdate=mdy(10, 08,1997) if gnumb==50
replace listdate=mdy(10, 08,1997) if gnumb==51
replace listdate=mdy(08, 20,2014) if gnumb==52
replace listdate=mdy(10, 08,1997) if gnumb==53
replace listdate=mdy(10, 08,1997) if gnumb==54
replace listdate=mdy(10, 08,1997) if gnumb==55
replace listdate=mdy(10, 08,1997) if gnumb==56
replace listdate=mdy(10, 08,1997) if gnumb==57
replace listdate=mdy(05, 16,2001) if gnumb==58
replace listdate=mdy(10, 08,1997) if gnumb==59
replace listdate=mdy(10, 08,1997) if gnumb==60
replace listdate=mdy(10, 08,1997) if gnumb==61
replace listdate=mdy(05, 18,2009) if gnumb==62
replace listdate=mdy(10, 08,1997) if gnumb==63
replace listdate=mdy(09, 01,2010) if gnumb==64
replace listdate=mdy(10, 08,1997) if gnumb==65
replace listdate=mdy(09, 10,2001) if gnumb==66
replace listdate=mdy(12, 17,2004) if gnumb==67
replace listdate=mdy(07, 02,2009) if gnumb==68

gen enddate=mdy(12,31,2017)
replace enddate=mdy(10,15,2010) if gnumb==16
replace enddate=mdy(10,08,1999) if gnumb==24
replace enddate=mdy(10,08,2001) if gnumb==40
replace enddate=mdy(10,08,1999) if gnumb==45
replace enddate=mdy(10,08,1999) if gnumb==50
replace enddate=mdy(09,28,2012) if gnumb==51
replace enddate=mdy(05,18,2009) if gnumb==59
replace enddate=mdy(09,03,2015) if gnumb==60
replace enddate=mdy(10,08,2001) if gnumb==65
replace enddate=mdy(07,15,2014) if gnumb==66
replace enddate=mdy(12,09,2015) if gnumb==67
*DFLP (gnumb==24) carries out 20 attacks after its removal from the list. The GTD records no activity for the group in the years 1995-2000. "The Manuel Rodriguez Patriotic Front Dissidents (FPMR/D) and the Democratic Front for the Liberation of Palestine (DFLP)* were dropped primarily because of the absence of terrorist activity, as defined by relevant law, by those groups during the past two years.... * The DFLP is still subject to the provisions of an Executive Order signed by President Clinton in January 1995 aimed at terrorist groups that threaten to disrupt the Middle East peace process. The Executive Order prohibits financial transactions with these terrorist groups and blocks their assets in the United States." https://www.state.gov/j/ct/rls/rpt/fto/2682.htm

format listdate %d
format enddate %d

gen listyear = year(listdate)
format listyear %ty

gen listendyear = year(enddate)
format listendyear %ty


gen postlist =.
replace postlist = 1 if year > listendyear


gen listtemp=1
replace listtemp=0 if gnumb==.
replace listtemp=0 if year < listyear
replace listtemp=2 if year == listyear
replace listtemp=0 if postlist==1

gen listtempdi=1
replace listtempdi=0 if listtemp==0
replace listtempdi=0 if listtemp==2

gen beflist1=.
replace beflist1=listyear-1
format beflist	%ty

gen prelist1=.
replace prelist1=1 if beflist==year

drop beflist



replace social_service=. if social_service==9


gen sponpre=.
replace sponpre=state_sponsor if prelist1==1
*16groups

gen mulbapre=.
replace mulbapre=mul_bases if prelist==1
*44groups

gen drugpre=.
replace drugpre=drugtk if prelist==1
*8 groups

gen socpre=.
replace socpre=social_service if prelist==1


gen alliespre=.
replace alliespre=num_allies if prelist==1
*17 groups

gen sizepre=.
replace sizepre=size if prelist==1
*4 groups

bysort gid (year): carryforward sponpre mulbapre drugpre socpre alliespre sizepre, replace



egen max_spon = max(state_sponsor), by(gid) 
replace max_spon=0 if max_spon==.
*21 groups
egen max_mulbase = max(mul_bases), by(gid) 
*62 groups
egen max_drug = max(drugtk), by(gid) 
*24 groups
egen pub_service = max(public_service), by(gid) 
*28 groups
egen max_allies = max(num_allies), by(gid) 
*39 groups
egen max_siz = max(size), by(gid)
*21 groups
sort gid year
drop public_service
rename pub_service public_service

sum max_allies


gen maxallieshi=.
replace maxallieshi=0 if max_allies<9
replace maxallieshi=1 if max_allies==9
replace maxallieshi=1 if max_allies==10
replace maxallieshi=1 if max_allies==18

sum maxallieshi

****Table 1: Descriptive Stats
set more off

xtsum fto listtempdi killtotal attacks age max_spon max_mulbase right left nat rel sq tch pch ercsr pccivtarg pcgovmiltarg hicap  
xtsum killtotal attacks age max_spon max_mulbase right left nat rel sq tch pch ercsr pccivtarg pcgovmiltarg hicap if listtempdi==1
xtsum killtotal attacks age pccivtarg pcgovmiltarg hicap if listtempdi==0 & fto==1
xtsum killtotal attacks age pccivtarg pcgovmiltarg hicap if fto==0



****Table 2
set more off
	
	eststo clear
		eststo: xtlogit fto age hicap rel right left nat sq tch pch ercsr max_mulbase max_spon, re
		esttab using Table2bEDTGFTO.rtf, se(2) title("Table 2: All EDTG Groups; Logit analysis with random-effects") eform		replace	 


*****Table 3		
	set more off	
	eststo clear
			eststo: xtnbreg killtotal i.fto i.listtempdi c.age i.rel i.right i.left i.nat i.sq i.tch i.pch i.ercsr i.max_mulbase i.max_spon, re irr
			eststo: xtnbreg attacks i.fto i.listtempdi c.age i.rel i.right i.left i.nat i.sq i.tch i.pch i.ercsr i.max_mulbase i.max_spon, re irr
			
		esttab using Table3EDTGirr.rtf, se(2) title("Table 3: All EDTG Groups; random-effects negative binomial regression with incidence rate ratios.") 	eform replace
			 
******Table 4		
set more off
		eststo clear
			 eststo: xtpoisson killtotal i.listtempdi c.age , fe irr
			 eststo: xtpoisson killtotal i.listtempdi##c.age i.rel##i.listtempdi i.right##i.listtempdi i.left##i.listtempdi i.nat##i.listtempdi i.sq##i.listtempdi i.tch##i.listtempdi i.pch##i.listtempdi i.ercsr##i.listtempdi i.max_mulbase##i.listtempdi i.max_spon##i.listtempdi, fe irr
			 eststo: xtpoisson attacks i.listtempdi c.age , fe irr
			 eststo: xtpoisson attacks i.listtempdi##c.age i.rel##i.listtempdi i.right##i.listtempdi i.left##i.listtempdi i.nat##i.listtempdi i.sq##i.listtempdi i.tch##i.listtempdi i.pch##i.listtempdi i.ercsr##i.listtempdi i.max_mulbase##i.listtempdi i.max_spon##i.listtempdi, fe irr
			 set more off
			 
			* "The fixed-effects model controls for all time-invariant differences between the individuals, so the estimated coefficients of the fixed-effects models cannot be biased because of omitted time-invariant characteristics" 
			 * - Kohler, Ulrich, Frauke Kreuter, Data Analysis Using Stata, 2nded., p.245
			 *fe negative binomial is not a true FE model and suffers from incidental parameters problem
		esttab using Table4EDTGirr.rtf, se(2) title("Table 4: All EDTG Groups; Poisson regression with fixed-effects & incidence rate ratios") 	eform	replace	 

	
*****Table 5 	
set more off
  eststo clear 
			
		eststo: xttobit pccivtarg i.fto c.age##i.listtempdi i.rel##i.listtempdi i.nat##i.listtempdi i.max_mulbase##i.listtempdi i.max_spon##i.listtempdi, ll(0) ul(1)
		eststo: xttobit pcgovmiltarg i.fto c.age##i.listtempdi i.rel##i.listtempdi i.nat##i.listtempdi i.max_mulbase##i.listtempdi i.max_spon##i.listtempdi, ll(0) ul(1)
		eststo: xttobit pccivtarg  c.age##i.listtempdi i.rel##i.listtempdi i.nat##i.listtempdi i.max_mulbase##i.listtempdi i.max_spon##i.listtempdi if fto==1, ll(0) ul(1) 
		eststo: xttobit pcgovmiltarg  c.age##i.listtempdi i.rel##i.listtempdi i.nat##i.listtempdi i.max_mulbase##i.listtempdi i.max_spon##i.listtempdi if fto==1, ll(0) ul(1)
	
esttab using Table5.rtf, se(2) title("Table 5: Random-effects Tobit models; Models 8-9 produced from full sample; Models 10-11 include FTO only (before and after proscription)") 	replace	 

******Table 6 
 set more off
  eststo clear 
		eststo: xtlogit hicap i.fto c.age i.listtempdi i.rel  i.nat i.max_mulbase i.max_spon , re  
		eststo: xtlogit hicap c.age##i.listtempdi , fe
		eststo: xtlogit hicap c.age##i.listtempdi i.rel##i.listtempdi i.nat##i.listtempdi i.max_mulbase##i.listtempdi i.max_spon##i.listtempdi, fe
esttab using Table6.rtf, eform se(2) title("Table 6: Models 12 random-effects logit; Models 13-14 fixed-effects logit") 	replace	 

	
	
****** Figure 1
	set more off
xtnbreg killtotal i.listtempdi##c.age i.rel##i.listtempdi if fto==1,  re 
		
margins listtempdi, at(age=(0(5)40) rel=(1)) saving(fileapp4b, replace)
preserve
use fileapp4b, clear
replace _margin=exp(_margin)
replace _ci_lb=exp( _ci_lb)
replace _ci_ub=exp( _ci_ub)
save fileapp4b, replace
combomarginsplot fileapp4b, title("Religious") labels("Not on list" "On list") name(irr, replace) legend(col(1) ring(0) pos(1)  ) 
restore
graph save relxList_fat, replace
rm fileapp4b.dta	

set more off
xtnbreg killtotal i.listtempdi##c.age i.rel##i.listtempdi if fto==1, re 
		
margins listtempdi, at(age=(0(5)40) rel=(0)) saving(fileapp4b, replace)
preserve
use fileapp4b, clear
replace _margin=exp(_margin)
replace _ci_lb=exp( _ci_lb)
replace _ci_ub=exp( _ci_ub)
save fileapp4b, replace
combomarginsplot fileapp4b, title("Secular") labels("Not on list" "On list") name(irr, replace) legend(col(1) ring(0) pos(1)  ) 
restore
graph save secxList_fat, replace
rm fileapp4b.dta	
		
				
set more off
xtnbreg attacks c.age##i.listtempdi i.rel##i.listtempdi if fto==1, re 
		
margins listtempdi, at(age=(0(5)40) rel=(1)) saving(fileapp4b, replace)
preserve
use fileapp4b, clear
replace _margin=exp(_margin)
replace _ci_lb=exp( _ci_lb)
replace _ci_ub=exp( _ci_ub)
save fileapp4b, replace
combomarginsplot fileapp4b, title("Religious") labels("Not on list" "On list") name(irr, replace) legend(col(1) ring(0) pos(1)  ) 
restore
graph save relxList, replace
rm fileapp4b.dta

		
set more off
xtnbreg attacks c.age##i.listtempdi i.rel##i.listtempdi if fto==1, re 
		
margins listtempdi, at(age=(0(5)40) rel=(0)) saving(fileapp4b, replace)
preserve
use fileapp4b, clear
replace _margin=exp(_margin)
replace _ci_lb=exp( _ci_lb)
replace _ci_ub=exp( _ci_ub)
save fileapp4b, replace
combomarginsplot fileapp4b, title("Secular") labels("Not on list" "On list") name(irr, replace) legend(col(1) ring(0) pos(1)  ) 
restore
graph save SecxList, replace
rm fileapp4b.dta



grc1leg2 relxList_fat.gph secxList_fat.gph relxList.gph SecxList.gph, ///
	xcommon   legendfrom(relxList_fat.gph) ///
	xtob1title ///
	saving("fourpanel_Rel.gph", replace)   title("Adjusted Predictions by Age & Proscription with 95%CIs")
	
	
	
*****Figure 2
	
set more off
xtnbreg killtotal i.listtempdi##c.age i.max_spon##i.listtempdi if fto==1, re 
		
margins listtempdi, at(age=(0(5)40) max_spon=(1)) saving(fileapp4b, replace)
preserve
use fileapp4b, clear
replace _margin=exp(_margin)
replace _ci_lb=exp( _ci_lb)
replace _ci_ub=exp( _ci_ub)
save fileapp4b, replace
combomarginsplot fileapp4b, title("Effect of Proscription on Sponsored Groups") labels("Not proscribed" "Proscribed") name(irr, replace) legend(col(1) ring(0) pos(1)  ) 
restore
graph save max_sponxList_fat, replace
rm fileapp4b.dta	

set more off
xtnbreg killtotal i.listtempdi##c.age i.max_spon##i.listtempdi if fto==1, re 
		
margins listtempdi, at(age=(0(5)40) max_spon=(0)) saving(fileapp4b, replace)
preserve
use fileapp4b, clear
replace _margin=exp(_margin)
replace _ci_lb=exp( _ci_lb)
replace _ci_ub=exp( _ci_ub)
save fileapp4b, replace
combomarginsplot fileapp4b, title("Not Sponsored ") labels("Not proscribed" "Proscribed") name(irr, replace) legend(col(1) ring(0) pos(1)  ) 
restore
graph save min_sponxList_fat, replace
rm fileapp4b.dta	
	
	
set more off
xtnbreg attacks  c.age##i.listtempdi i.max_spon##i.listtempdi if fto==1, re 
		
margins listtempdi, at(age=(0(5)40) max_spon=(1)) saving(fileapp4b, replace)
preserve
use fileapp4b, clear
replace _margin=exp(_margin)
replace _ci_lb=exp( _ci_lb)
replace _ci_ub=exp( _ci_ub)
save fileapp4b, replace
combomarginsplot fileapp4b, title("Sponsored Groups") labels("Not proscribed" "Proscribed") name(irr, replace) legend(col(1) ring(0) pos(1)  ) 
restore
graph save max_sponxList, replace
rm fileapp4b.dta


set more off
xtnbreg attacks  c.age##i.listtempdi i.max_spon##i.listtempdi if fto==1, re 
		
margins listtempdi, at(age=(0(5)40) max_spon=(0)) saving(fileapp4b, replace)
preserve
use fileapp4b, clear
replace _margin=exp(_margin)
replace _ci_lb=exp( _ci_lb)
replace _ci_ub=exp( _ci_ub)
save fileapp4b, replace
combomarginsplot fileapp4b, title("Not Sponsored Groups") labels("Not proscribed" "Proscribed") name(irr, replace) legend(col(1) ring(0) pos(1)  ) 
restore
graph save min_sponxList, replace
rm fileapp4b.dta


grc1leg2 max_sponxList_fat.gph min_sponxList_fat.gph max_sponxList.gph min_sponxList.gph,  ///
	xcommon   legendfrom(max_sponxList_fat.gph) ///
	xtob1title ///
	saving("fourpanel_Spon.gph", replace)   title("Adjusted Predictions by Age & Proscription with 95%CIs")
	
	
***** Figure 3

set more off
xtnbreg killtotal i.listtempdi##c.age i.nat##i.listtempdi if fto==1, re 
		
margins listtempdi, at(age=(0(5)40) nat=(1)) saving(fileapp4b, replace)
preserve
use fileapp4b, clear
replace _margin=exp(_margin)
replace _ci_lb=exp( _ci_lb)
replace _ci_ub=exp( _ci_ub)
save fileapp4b, replace
combomarginsplot fileapp4b, title("Nationalist Groups") labels("Not proscribed" "Proscribed") name(irr, replace) legend(col(1) ring(0) pos(1)  ) 
restore
graph save natxList_fat, replace
rm fileapp4b.dta	

set more off
xtnbreg killtotal i.listtempdi##c.age i.nat##i.listtempdi if fto==1, re 
		
margins listtempdi, at(age=(0(5)40) nat=(0)) saving(fileapp4b, replace)
preserve
use fileapp4b, clear
replace _margin=exp(_margin)
replace _ci_lb=exp( _ci_lb)
replace _ci_ub=exp( _ci_ub)
save fileapp4b, replace
combomarginsplot fileapp4b, title("Not Nationalist Groups") labels("Not proscribed" "Proscribed") name(irr, replace) legend(col(1) ring(0) pos(1)  ) 
restore
graph save notnatxList_fat, replace
rm fileapp4b.dta	
	
	
set more off
xtnbreg attacks  c.age##i.listtempdi i.nat##i.listtempdi if fto==1, re 
		
margins listtempdi, at(age=(0(5)40) nat=(1)) saving(fileapp4b, replace)
preserve
use fileapp4b, clear
replace _margin=exp(_margin)
replace _ci_lb=exp( _ci_lb)
replace _ci_ub=exp( _ci_ub)
save fileapp4b, replace
combomarginsplot fileapp4b, title("Nationalist Groups") labels("Not proscribed" "Proscribed") name(irr, replace) legend(col(1) ring(0) pos(1)  ) 
restore
graph save natxList, replace
rm fileapp4b.dta


set more off
xtnbreg attacks  c.age##i.listtempdi i.nat##i.listtempdi if fto==1, re 
		
margins listtempdi, at(age=(0(5)40) nat=(0)) saving(fileapp4b, replace)
preserve
use fileapp4b, clear
replace _margin=exp(_margin)
replace _ci_lb=exp( _ci_lb)
replace _ci_ub=exp( _ci_ub)
save fileapp4b, replace
combomarginsplot fileapp4b, title("Not Nationalist Groups") labels("Not proscribed" "Proscribed") name(irr, replace) legend(col(1) ring(0) pos(1)  ) 
restore
graph save notnatxList, replace
rm fileapp4b.dta


grc1leg2 natxList_fat.gph notnatxList_fat.gph natxList.gph notnatxList.gph ,  ///
	xcommon   legendfrom(natxList_fat.gph) ///
	xtob1title ///
	saving("fourpanel_Nat.gph", replace)   title("Adjusted Predictions by Age & Proscription with 95%CIs")
	

**** Figure 4

set more off
xttobit pccivtarg  c.age##i.listtempdi i.rel##i.listtempdi i.nat##i.listtempdi i.max_mulbase##i.listtempdi i.max_spon##i.listtempdi if fto==1, ll(0) ul(1) 
margins listtempdi, at(age=(0 40) rel=(0 ) ) saving(fileapp4b, replace)
preserve
use fileapp4b, clear

save fileapp4b, replace
combomarginsplot fileapp4b,  title("Secular") labels("Not proscribed" "Proscribed")  legend(col(1) ring(0) pos(1)  ) 
restore
graph save pcciv_bsec, replace
rm fileapp4b.dta


set more off
xttobit pccivtarg  c.age##i.listtempdi i.rel##i.listtempdi i.nat##i.listtempdi i.max_mulbase##i.listtempdi i.max_spon##i.listtempdi if fto==1, ll(0) ul(1) 
margins listtempdi, at(age=(0 40) rel=(1) ) saving(fileapp4b, replace)
preserve
use fileapp4b, clear

save fileapp4b, replace
combomarginsplot fileapp4b,  title("Religious") labels("Not proscribed" "Proscribed") legend(col(1) ring(0) pos(1)  ) 
restore
graph save pcciv_brel, replace
rm fileapp4b.dta



gr combine pcciv_bsec.gph pcciv_brel.gph, ///
	name("relciv", replace) ycommon cols(2) title("Targeting of Civilians")

****Figure 5

set more off
xttobit pcgovmiltarg i.fto c.age##i.listtempdi i.rel##i.listtempdi i.nat##i.listtempdi i.max_mulbase##i.listtempdi i.max_spon##i.listtempdi, ll(0) ul(1)
margins listtempdi, at(age=(0 40)  ) saving(fileapp5, replace)
preserve
use fileapp5, clear

save fileapp5, replace
combomarginsplot fileapp5,  title("Full Sample") labels("Not proscribed" "Proscribed")  legend(col(1) ring(0) pos(1)  ) 
restore
graph save pcgmil, replace
rm fileapp5.dta


set more off
xttobit pcgovmiltarg  c.age##i.listtempdi i.rel##i.listtempdi i.nat##i.listtempdi i.max_mulbase##i.listtempdi i.max_spon##i.listtempdi if fto==1, ll(0) ul(1)
margins listtempdi, at(age=(0 40)  ) saving(fileapp5, replace)
preserve
use fileapp5, clear

save fileapp5, replace
combomarginsplot fileapp5,  title("FTO Only") labels("Not proscribed" "Proscribed") legend(col(1) ring(0) pos(1)  ) 
restore
graph save pcgovFTO, replace
rm fileapp5.dta



gr combine pcgmil.gph pcgovFTO.gph, ///
	name("pcgmiltarg", replace) ycommon xcommon cols(2) title("Targeting of Govt/Military") 


	set more off 
xttobit pchicapmode i.fto c.age i.listtempdi i.rel  i.nat i.max_mulbase i.max_spon , ll(0) ul(1)
margins listtempdi, at(age=(0 40)  ) saving(fileapp7, replace)
preserve
use fileapp7, clear

save fileapp7, replace
combomarginsplot fileapp7,  title("Full Model") labels("Not proscribed" "Proscribed") legend(col(1) ring(0) pos(1)  ) 
restore
graph save pchicap, replace
rm fileapp7.dta
	
xttobit pchicapmode c.age##i.listtempdi i.rel##i.listtempdi i.nat##i.listtempdi i.max_mulbase##i.listtempdi i.max_spon##i.listtempdi if fto==1, ll(0) ul(1)

